package com.example.month2;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.Toast;

public class MyDataDialog extends Dialog {
    Context context;
    public MyDataDialog(Context context) {
        super(context);
        this.context = context;
    }
    private DatePicker dp;
    private Button queding;
    private Button quxiao;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mydata);
//        setCanceledOnTouchOutside(false);
        dp=findViewById(R.id.data_picker);
        queding = findViewById(R.id.queding);
        quxiao=findViewById(R.id.quxiao);
        queding.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context,dp.getYear()+"年"+(dp.getMonth()+1)+"月",Toast.LENGTH_SHORT).show();
                MyDataDialog.this.dismiss();
            }
        });
        quxiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context,"取消",Toast.LENGTH_SHORT);
                MyDataDialog.this.dismiss();
            }
        });
    }



}
